home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 6 / The Arsenal Files 6 (Arsenal Computer).ISO / prg_casm / jlvesa11.zip / JLVESA.H < prev    next >
Text File  |  1996-01-03  |  10KB  |  230 lines

  1. /********************************************************************
  2. *  JLVesa SVGA library
  3. *  Copyright 1995 Johannes Lehtinen
  4. *  All rights reserved
  5. ********************************************************************/
  6.  
  7. #ifndef __JV_JLVESA_H__
  8. #define __JV_JLVESA_H__
  9.  
  10. /********************************************************************
  11. *  Some constant #defines
  12. ********************************************************************/
  13.  
  14. #define JV_SUCCESS 0
  15. #define JV_FAILURE 1
  16.  
  17. /********************************************************************
  18. *  Some type definitions for unsigned/signed bytes, words and dwords
  19. ********************************************************************/
  20.  
  21. typedef unsigned long int JVUDword;
  22. typedef unsigned short int JVUWord;
  23. typedef unsigned char JVUByte;
  24. typedef signed long int JVSDword;
  25. typedef signed short int JVSWord;
  26. typedef signed char JVSByte;
  27.  
  28. typedef unsigned char JVFlag;
  29. typedef JVUByte JVPalette[256][3];
  30.  
  31. typedef struct JVFont
  32. {
  33.    JVUWord offset[256];       /* Offsets of character images. If the
  34.                               *  character does not have corresponding
  35.                               *  object, 0xFFFF is used. */
  36.    JVUWord height;            /* Height of font */
  37.    JVUWord width;             /* Default width for character cell.
  38.                               *  Different characters may still have
  39.                               *  different width. */
  40.    JVUByte *font_data;        /* Font images. First byte of image is
  41.                                * the actual length of the character.
  42.                                * Rest of the data is like any image. */
  43. };
  44.  
  45. /*********************************************************************
  46. *  Data structures used
  47. *********************************************************************/
  48.  
  49. /* Data structure for VESA SVGA info */
  50.  
  51. struct JVSVGAInfo
  52. {
  53.    JVUByte signature[4];      /* Signature "VESA" */
  54.    JVUByte ver_minor, ver_major; /* Version number */
  55.    char *oem_name;            /* OEM-name of the VESA */
  56.    JVUDword capabilities;     /* Capabilities (no exact info available) */
  57.    JVUWord (*modes)[];        /* List of supported VESA-modes (terminated
  58.                                  with 0ffffH) */
  59.    JVUWord memory;            /* Amount of memory in 64Kb blocks */
  60.    JVUByte reserved[236];     /* Reserved for future use */
  61. };
  62.  
  63. /* Data structure for VESA mode info */
  64.  
  65. struct JVModeInfo
  66. {
  67.    struct                     /* Mode attributes */
  68.    {
  69.       int support : 1;        /* Set if mode supported */
  70.       int optional_info : 1;  /* Set if optional info available */
  71.       int BIOS_support : 1;   /* Set if BIOS output supported */
  72.       int color : 1;          /* Set if color mode */
  73.       int graphics : 1;       /* Set if graphics mode */
  74.       int reserved : 11;      /* Not used */
  75.    } mode_attr;
  76.    struct                     /* Window attributes */
  77.    {
  78.       int A_exists : 1;       /* Set if window A exists */
  79.       int A_readable : 1;     /* Set if window A readable */
  80.       int A_writable : 1;     /* Set if window A writable */
  81.       int A_reserved : 5;     /* Reserved */
  82.       int B_exists : 1;       /* Set if window B exists */
  83.       int B_readable : 1;     /* Set if window B readable */
  84.       int B_writable : 1;     /* Set if window B writable */
  85.       int B_reserved : 5;     /* Reserved */
  86.    } win_attr;
  87.    JVUWord win_granularity;   /* Window granularity in kilobytes */
  88.    JVUWord win_size;          /* Window size in kilobytes */
  89.    JVUWord winA_seg;          /* Start segment of window A */
  90.    JVUWord winB_seg;          /* Start segment of window B */
  91.    JVUDword pos_func;         /* Window positioning function */
  92.    JVUWord bytes_per_line;    /* Bytes per scan line */
  93.  
  94.    /* Following is optional information, check mode_attr.optional_info */
  95.  
  96.    JVUWord width;             /* Width in pixels */
  97.    JVUWord height;            /* Height in pixels */
  98.    JVUByte char_width;        /* Width of character cell in pixels */
  99.    JVUByte char_height;       /* Height of character cell in pixels */
  100.    JVUByte planes;            /* Number of memory planes */
  101.    JVUByte bits_per_pixel;    /* Number of bits per pixel */
  102.    JVUByte banks;             /* Number of memory banks */
  103.    JVUByte model;             /* Memory model type
  104.                                     0 - Text mode
  105.                                     1 - CGA graphics
  106.                                     2 - Hercules graphics
  107.                                     3 - EGA 16 colors
  108.                                     4 - packed pixels
  109.                                     5 - non chain 4 256 color modes
  110.                                     6 - direct 15/16/24 bits
  111.                                     7 - YUV */
  112.    JVUByte bank_size;         /* Size of memory bank */
  113.    JVUByte pages;             /* Number of image pages -1 */
  114.    JVUByte reserved1;         /* Reserved */
  115.  
  116.    /* Following are available in VESA v1.02+ */
  117.  
  118.    JVUByte red_size;          /* Red mask size */
  119.    JVUByte red_pos;           /* Red mask position */
  120.    JVUByte green_size;        /* Green mask size */
  121.    JVUByte green_pos;         /* Green mask position */
  122.    JVUByte blue_size;         /* Blue mask size */
  123.    JVUByte blue_pos;          /* Blue mask position */
  124.    JVUByte res_size;          /* Reserved mask size */
  125.    JVUByte res_pos;           /* Reserved mask position */
  126.    JVUByte direct_info;       /* Direct screen mode info */
  127.    JVUByte reserved2[215];    /* Reserved */
  128. };
  129.  
  130. typedef struct JVSVGAInfo JVSVGAInfo;
  131. typedef struct JVModeInfo JVModeInfo;
  132.  
  133. /******************************************************************
  134. *  Defines for those who are using old function names. Remember to
  135. *  define JV_OLD_FUNC_NAMES, if using old function names!
  136. ******************************************************************/
  137.  
  138. #ifdef JV_OLD_FUNC_NAMES
  139.  
  140. #define vesa_svga_info JVSVGA_GetInfo
  141. #define vesa_mode_info JVSVGA_GetModeInfo
  142. #define vesa_set_mode JVSVGA_SetMode
  143. #define vesa_get_mem JVSVGA_GetMemory
  144. #define vesa_set_vstart JVScreen_SetVisual
  145. #define vesa_clr_mem JVScreen_ClearAll
  146. #define vesa_put_pixel JVPixel_Draw
  147. #define vesa_draw_block JVRectangle_Draw
  148. #define vesa_draw_line JVLine_Draw
  149. #define vesa_put_image JVImage_Draw
  150. #define vesa_put_image_on JVImage_DrawOn
  151. #define vesa_vretrace JVSVGA_WaitForVRetrace
  152. #define vesa_set_palette JVPalette_Set
  153. #define vesa_get_image JVImage_Read
  154. #define vesa_set_astart JVScreen_SetActive
  155. #define vesa_set_lwidth JVScreen_SetLogicalWidth
  156. #define vesa_set_color JVColor_Set
  157. #define vesa_find_color JVColor_Find
  158. #define vesa_put_image_limit JVImage_DrawLimited
  159. #define vesa_put_image_on_limit JVImage_DrawOnLimited
  160. #define vesa_get_pixel JVPixel_Read
  161. #define vesa_select_font JVFont_Select
  162. #define vesa_put_text JVText_Draw
  163. #define vesa_colorize_font JVFont_Colorize
  164. #define vesa_strlen JVText_GetLength
  165. #define vesa_get_text JVText_Input
  166. #define vesa_draw_line_limit JVLine_DrawLimited
  167.  
  168. #endif
  169.  
  170. /******************************************************************
  171. *  Function prototypes
  172. ******************************************************************/
  173.  
  174. #ifdef __cplusplus
  175. extern "C" {
  176. #endif
  177.  
  178.    JVFlag JVSVGA_GetInfo(JVSVGAInfo *info);
  179.    JVFlag JVSVGA_GetModeInfo(JVUWord mode, JVModeInfo *info);
  180.    JVUDword JVSVGA_GetMemory(void);
  181.    JVFlag JVSVGA_SetMode(JVUWord mode);
  182.    void JVSVGA_WaitForVRetrace(void);
  183.    void JVScreen_SetActive(JVUDword offset);
  184.    JVFlag JVScreen_SetVisual(JVUWord pixel, JVUWord line);
  185.    JVUWord JVScreen_SetLogicalWidth(JVUWord lwidth);
  186.    void JVScreen_ClearAll(JVUByte color);
  187.    void JVPixel_Draw(JVSWord x, JVSWord y, JVUByte color);
  188.    JVUByte JVPixel_Read(JVSWord x, JVSWord y);
  189.    void JVRectangle_Draw(JVSWord x, JVSWord y, JVUWord width, JVUWord height,
  190.                          JVUByte color);
  191.    void JVLine_Draw(JVSWord x1, JVSWord y1, JVSWord x2, JVSWord y2,
  192.                     JVUByte color);
  193.    void JVImage_Draw(JVSWord x, JVSWord y, JVUWord width, JVUWord height,
  194.                      void *image);
  195.    void JVImage_DrawOn(JVSWord x, JVSWord y, JVUWord width,
  196.                        JVUWord height, void *image);
  197.    void JVImage_DrawLimited(JVSWord x, JVSWord y, JVUWord width,
  198.                             JVUWord height, void *image, JVSWord lx,
  199.                             JVSWord ly, JVUWord lwidth, JVUWord lheight);
  200.    void JVImage_DrawOnLimited(JVSWord x, JVSWord y, JVUWord width,
  201.                               JVUWord height, void *image, JVSWord lx,
  202.                               JVSWord ly, JVUWord lwidth, JVUWord lheight);
  203.    void JVImage_Read(JVSWord x, JVSWord y, JVUWord width, JVUWord height,
  204.                      void *image);
  205.    void JVPalette_Set(JVPalette palette);
  206.    void JVColor_Set(JVUByte color, JVUByte red, JVUByte green, JVUByte blue);
  207.    JVUByte JVColor_Find(JVPalette palette, JVUByte red, JVUByte green,
  208.                         JVUByte blue);
  209.    void JVBIOS_SetMode(JVUByte mode);
  210.  
  211. #ifdef __cplusplus
  212. }
  213. #endif
  214.  
  215. #ifdef __cplusplus
  216.  
  217.    void JVFont_Select(JVFont *font);
  218.    void JVText_Draw(int x, int y, char *string);
  219.    void JVFont_Colorize(JVUByte color);
  220.    int JVText_GetLength(char *string);
  221.    void JVText_Input(int x, int y, char *string, int maxlength,
  222.                      JVUByte fgcolor, JVUByte bgcolor);
  223.    void JVLine_DrawLimited(int x1, int y1, int x2, int y2, JVUByte color,
  224.                            int xl, int yl, int width, int height);
  225.  
  226. #endif
  227.  
  228. #endif
  229.  
  230.